<template>
  <div class="school">
    <h2>学校名称: {{ name }}</h2>
    <h2>学校地址: {{ address }}</h2>
    <button @click="sendSchoolName">把学校名传给App</button>
  </div>
</template>

<script>
  export default {
    name: 'School',
    props: ['getSchoolName'],
    data() {
      return {
        name: '尚硅谷',
        address: '广东深圳'
      }
    },
    methods: {
      sendSchoolName() {
        this.getSchoolName(this.name)
      }
    }
  }
</script>

<style scoped>  /* TODO 加了 scoped 标记，表示样式只对当前组件有效 */
  .school {
    background-color: skyblue;
    padding: 5px;
  }
</style>